<template>
	<view class="app-apply e-rela">
		<image class="app-apply__bg1" :src="$staticPath('string/string_bg1.png')" mode="scaleToFill"></image>
		<image class="app-apply__bg z-index2" :src="$staticPath('string/string_bg1.png')" mode="widthFix"></image>
		<view class="app-apply__content">
			<view class="e-p-l-20 e-p-r-20">
				<view class="bg-white e-radius-20 app-apply__panel e-p-t-50">
					<view class="e-m-b-48 e-flex">
						<view class="e-flex-1">
							<view class="text-center e-m-b-16 e-font-34 w-500" style="color: #4B68E3;">
								{{info.packNumber || 0}}
							</view>
							<view class="c-333 e-font-26 text-center">
								兑换包
							</view>
						</view>
						<!-- <view class="e-flex-1">
							<view class="text-center e-m-b-16 e-font-34 w-500" style="color: #4B68E3;">
								0
							</view>
							<view class="c-333 e-font-26 text-center">
								融耀石刻手串
							</view>
						</view> -->
						<view class="e-flex-1">
							<view class="text-center e-m-b-16 e-font-34 w-500" style="color: #4B68E3;">
								{{info.freezeMoney || 0}}
							</view>
							<view class="c-333 e-font-26 text-center">
								消费积分
							</view>
						</view>
					</view>
					<view class="e-p-l-40 e-p-r-40">
						<view class="e-flex-xy-center app-apply__btn" @tap="submit">
							<text class="e-font-32 c-white w-500">{{applyStatus?'申请中':'开始兑换'}}</text>
						</view>
					</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import {applyDay,getDayPre,checkApply} from '@/common/request/api'
	export default {
		data() {
			return {
				loading:false,
				info:{},
				applyStatus:false
			}
		},
		onShow() {
			this.handleCheck()
			getDayPre().then(res => {
				if (res.code == 200) {
					this.info= res.data
				}
			})
		},
		methods:{
			handleCheck() {
				uni.showLoading()
				checkApply({releaseType:1}).then(res => {
					this.applyStatus = res.data
				}).finally(() => {
					uni.hideLoading()
				})
			},
			submit() {
				if(this.applyStatus) return
				if (this.loading) return
				this.loading = true
				uni.showLoading()
				applyDay().then(res => {
					if (res.code == 200) {
						this.$toastApp('申请成功')
						setTimeout(() => {
							this.handleCheck()
						},1000)
					}
				}).finally(() =>{
					uni.hideLoading()
					this.loading = false
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.z-index2{
		position: relative;
		z-index: 2;
	}
	@include appBem_b(apply) {
		height: 100vh;
		@include appBem_e(bg) {
			width: 100vw;
		}
		@include appBem_e(bg1) {
			width: 100vw;
			height: 100vh;
			position: absolute;
			top: 0;
			left: 0;
			z-index: 1;
		}
		@include appBem_e(content) {
			position: fixed;
			bottom: 162rpx;
			width: 100vw;
			z-index: 999;
		}
		@include appBem_e(panel) {
			height: 348rpx;
		}
		@include appBem_e(btn) {
			height: 100rpx;
			background: #4B68E3;
			border-radius: 50rpx;
		}

	}
	.img-458 {
		width: 458rpx;
	}
</style>